home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2a.lha / p4-1.2a / messages_f / sr1_master.f < prev    next >
Text File  |  1992-10-19  |  1KB  |  59 lines

  1.       program master
  2.  
  3.       include 'p4f.h'
  4.  
  5.       integer i,slaves,type,from,retcde,recvlen,buflen,loops,time
  6.       character*500 buffer
  7.       integer TAGCNT, TAGDAT, TAGEND
  8.       parameter (TAGCNT = 10)
  9.       parameter (TAGDAT = 20)
  10.       parameter (TAGEND = 30)
  11.  
  12.       call p4init()
  13.       call p4crpg()
  14.  
  15.       slaves = p4ntotids() - 1
  16.       length = 0
  17.       buflen = 0
  18.  
  19.       do 10 i = 1,slaves
  20.          call p4sendr(TAGCNT,i,buffer,length,retcde)
  21. 10    continue
  22.  
  23. 20    print *,'How long is the message: '
  24.       read (*,*,end=50) buflen
  25.       buflen = MIN(500,buflen)
  26.  
  27. 25    print *,'How many times around the loop? '
  28.       read (*,*,end=50) loops
  29.  
  30.       length = buflen 
  31.       time = p4clock()
  32.       do 45 j=1,loops
  33.  
  34. C send in reverse order of the slaves
  35.       call p4send(TAGDAT,slaves,buffer,length,retcde)
  36.       buffer = ' ' 
  37.       type = TAGDAT
  38.       from = -1
  39.       call p4recv(type,from,buffer,buflen,recvlen,type,retcde)
  40.  
  41.       print *,'Loop number = ',j
  42.       print 101,'MASTER receives from = ',from,' length = ',recvlen
  43. 101   format(a,i2,a,i6,/)
  44.       length = recvlen 
  45. 45    continue 
  46.       oldtime = time
  47.       time = p4clock()
  48.       print *,'Time used: ',time-oldtime, ' milliseconds'
  49.       length = 0
  50. 50    continue
  51.  
  52.       do 60 i = 1,slaves
  53.          call p4sendr(TAGEND,i,buffer,buflen,retcde)
  54. 60    continue
  55.  
  56.       call p4cleanup()
  57.       print *,'Master exiting normally'
  58.       end
  59.